﻿<Page
    x:Name="pageRoot"
    x:Class="BootyBay.PrivateStoreApp.ItemDetailPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BootyBay.PrivateStoreApp"
    xmlns:data="using:BootyBay.PrivateStoreApp.Data"
    xmlns:control="using:BootyBay.PrivateStoreApp.Controls"
    xmlns:common="using:BootyBay.PrivateStoreApp.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Unloaded="pageRoot_Unloaded"
    >
    <Page.TopAppBar>
        <AppBar BorderThickness="1" BorderBrush="#99205B96" Margin="0,-2,0,0">
            <Grid Height="105" Background="#99205B96">
                <StackPanel Orientation="Horizontal">
                    <Button Margin="27,0,0,0" Content="主页" Background="#77ACE1" BorderThickness="0" Style="{StaticResource AppsPage_Home_ButtonStyle}" x:Name="btn_Home" Click="btn_Home_Click"></Button>
                    <Button Margin="10,0,0,0" Content="你的应用" Background="#77ACE1" BorderThickness="0" Style="{StaticResource AppsPage_YourApps_ButtonStyle}" x:Name="btn_AppList" Click="btn_AppList_Click"></Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>
    <Page.Resources>
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></common:BooleanToVisibilityConverter>
        <common:CategoryNameConverter x:Key="CategoryNameConverter"></common:CategoryNameConverter>
        <common:GetAppSizeByAppNameConverter x:Key="GetAppSizeByAppNameConverter"></common:GetAppSizeByAppNameConverter>
        <common:ProcessorArchitectureConverter x:Key="ProcessorArchitectureConverter"></common:ProcessorArchitectureConverter>
        <common:StringToShowNameConverter x:Key="StringToShowNameConverter"></common:StringToShowNameConverter>
        <common:StringToHitButtonConverter x:Key="StringToHitButtonConverter"></common:StringToHitButtonConverter>
    </Page.Resources> 
    <!--
        此网格用作定义以下两行的页的根面板: 
        * 第 0 行包含后退按钮和页标题
        * 第 1 行包含页布局的其余部分
    -->
    <Grid
        d:DataContext="{Binding Groups[0].Items[0], Source={d:DesignData Source=/DataModel/SampleData.json, Type=data:SampleDataSource}}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.Background>
            <ImageBrush ImageSource="Images/bg.png"></ImageBrush>
        </Grid.Background>
        <!--
            TODO: 应将内容放入以下网格
                  以显示当前项的详细信息
        -->
        <Hub SectionHeaderClick="Hub_SectionHeaderClick" x:Name="hub_control">
            <Hub.Header>
                <!-- 后退按钮和页标题-->
                <Grid DataContext="{Binding appDetailPageVM.AppModel.AppView}" Width="{Binding ElementName=hub_control,Path=ActualWidth}" Margin="0,-35,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <HyperlinkButton x:Name="hyperLink_install" Visibility="Collapsed" Content="{Binding ApplicationName}" Click="hyperLink_install_Click" FontFamily="微软雅黑" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.ColumnSpan="2" Padding="0,15,85,0"></HyperlinkButton>
                    <Button x:Name="backButton" Margin="0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Center"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
                    <TextBlock x:Name="pageTitle" Text="{Binding ApplicationName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="0,0,30,0" Padding="0,20,0,30"/>
                </Grid>
            </Hub.Header>
            <HubSection Width="417" VerticalAlignment="Top">
                <DataTemplate>
                    <Grid Margin="80,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" Height="32" Background="#00000000" DataContext="{Binding appDetailPageVM}">
                            <Button Visibility="{Binding IsActionRequired, Converter={StaticResource BooleanToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,0" Content="{Binding ActionName,Converter={StaticResource StringToShowNameConverter}}" IsHitTestVisible="{Binding ActionName,Converter={StaticResource StringToHitButtonConverter}}" Background="#77ACE1" BorderThickness="0" Style="{StaticResource ItemDetailPage_install_ButtonStyle}" Command="{Binding RequestInstallationCommand}" Click="btn_Install_Click"></Button>
                        </Border>
                        <TextBlock Grid.Row="1" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_explain_TextStyle}" Text="当你安装应用时，即表示你同意使用条款和任附加条款"></TextBlock>
                        <TextBlock Grid.Row="2" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_explain_TextStyle}" Text="此应用具有使用你电脑某些功能的权限，这可能会对你的隐私有所影响"></TextBlock>
                        <TextBlock Grid.Row="3" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="描述"></TextBlock>
                        <TextBlock Grid.Row="4" Margin="0,8,0,0" Style="{StaticResource ItemDetailPage_english_TextStyle}" DataContext="{Binding appDetailPageVM.AppModel.AppView}" Text="{Binding Description}"></TextBlock>
                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection Width="844" DataContext="{Binding appDetailPageVM.AppModel.AppView}">
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="20"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Border  Grid.Row="0" Grid.ColumnSpan="2" Width="820" Height="410" HorizontalAlignment="Left" VerticalAlignment="Top" Background="#00999999">
                            <control:FlipViewControl></control:FlipViewControl>
                        </Border>
                        <Grid Grid.Row="2" Grid.ColumnSpan="2" Margin="95,0,0,0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="260"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource ItemDetailPage_explain_TextStyle}">
                                    <Run Text="发行者"></Run>
                                    <Run Text="{Binding PublisherDisplayName}"></Run>
                            </TextBlock>
                            <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource ItemDetailPage_explain_TextStyle}">
                                    <Run Text="类别 "></Run>
                                    <Run Text="{Binding CategoryText}"></Run>
                            </TextBlock>
                        </Grid>

                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection DataContext="{Binding appDetailPageVM.AppModel.AppView}" Header="详细信息">
                <DataTemplate>
                    <Grid Margin="0,0,20,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Margin="0,0,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="关键字："></TextBlock>
                        <TextBlock Grid.Row="1" Margin="0,8,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="{Binding Keywords}"></TextBlock>
                        <TextBlock Grid.Row="2" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="支持的处理器："></TextBlock>
                        <TextBlock Grid.Row="3" Margin="0,8,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="{Binding ProcessorArchitecture,Converter={StaticResource ProcessorArchitectureConverter}}"></TextBlock>
                        <TextBlock Grid.Row="4" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="主版本号："></TextBlock>
                        <TextBlock Grid.Row="5" Margin="0,8,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="{Binding MajorVersion}"></TextBlock>
                        <TextBlock Grid.Row="6" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="上架时间："></TextBlock>
                        <TextBlock Grid.Row="7" Margin="0,8,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="{Binding CreationDate}"></TextBlock>
                        <TextBlock Grid.Row="8" Margin="0,30,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="更新时间："></TextBlock>
                        <TextBlock Grid.Row="9" Margin="0,8,0,0" Style="{StaticResource ItemDetailPage_description_TextStyle}" Text="{Binding OperationDate}"></TextBlock>
                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection Header="相关应用" IsHeaderInteractive="True" DataContext="{Binding applistCategoryVM}">
                <DataTemplate>
                    <GridView x:Name="itemGridView"
                              ItemsSource="{Binding CategoryAppData}"
                              Margin="-9,0,0,0"
                              AutomationProperties.AutomationId="ItemGridView"
                              AutomationProperties.Name="Items In Group"
                              ItemTemplate="{StaticResource AppListItemTemplate}"
                              SelectionMode="None"
                              IsSwipeEnabled="false"
                              IsItemClickEnabled="True"
                              ItemClick="itemGridView_ItemClick"
                              >
                    </GridView>
                </DataTemplate>
            </HubSection>
        </Hub>
    </Grid>
</Page>
